package com.cskaoyan.beanwx.vo;

import lombok.Data;

/**
 * Vo viewObject
 * @param <T>
 * 这是前后端分离，json数据一个常用的格式
 */
@Data
public class WxBaseRespVo<T> {

    String errmsg;//告诉前端请求的消息
    long errno;//自己的前后端应用 ： 自定义的状态码 → 通常前端根据该状态码做不同的处理

    public static WxBaseRespVo ok(){
        WxBaseRespVo<Object> baseRespVo = new WxBaseRespVo<>();
        baseRespVo.setErrno(0);
        baseRespVo.setErrmsg("成功");
        return baseRespVo;
    }
    public static WxBaseRespVo ok(Object data){
        WxBaseRespVo<Object> baseRespVo = new WxBaseRespVo<>();
        baseRespVo.setErrno(0);
        baseRespVo.setErrmsg("成功");
        return baseRespVo;
    }
    public static WxBaseRespVo ok(Object data, String msg){
        WxBaseRespVo<Object> baseRespVo = new WxBaseRespVo<>();
        baseRespVo.setErrno(0);
        baseRespVo.setErrmsg(msg);
        return baseRespVo;
    }
    public static WxBaseRespVo fail(){
        WxBaseRespVo<Object> baseRespVo = new WxBaseRespVo<>();
        baseRespVo.setErrno(500);
        baseRespVo.setErrmsg("失败");
        return baseRespVo;
    }
    public static WxBaseRespVo fail(String msg){
        WxBaseRespVo<Object> baseRespVo = new WxBaseRespVo<>();
        baseRespVo.setErrno(605);
        baseRespVo.setErrmsg(msg);
        return baseRespVo;
    }
    public static WxBaseRespVo fail2(String msg){
        WxBaseRespVo<Object> baseRespVo = new WxBaseRespVo<>();
        baseRespVo.setErrno(402);
        baseRespVo.setErrmsg(msg);
        return baseRespVo;
    }
}
